package cn.wqk.demo.controller;

import cn.wqk.demo.pojo.User;
import cn.wqk.demo.service.UserService;
import cn.wqk.demo.utils.JWTUtils;
import com.auth0.jwt.exceptions.AlgorithmMismatchException;
import com.auth0.jwt.exceptions.InvalidClaimException;
import com.auth0.jwt.exceptions.SignatureVerificationException;
import com.auth0.jwt.exceptions.TokenExpiredException;
import com.auth0.jwt.interfaces.DecodedJWT;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 吴青珂
 * @Date: 2020/12/25/14:08
 * @Description:
 */
@RestController
@Slf4j
@RequestMapping("user")
@CrossOrigin("*")
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping("/allUser")
    public Map<String,Object> allUser(HttpServletRequest request){
        String token = request.getHeader("token");
        log.info("token->[{}]",token);
        List<User> userList = userService.allUser();
        HashMap<String, Object> returnMap = new HashMap<>();
        returnMap.put("status",true);
        returnMap.put("data",userList);
        return returnMap;
    }
}
